package MyReflect03;

import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class demo {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Properties prop = new Properties();
        FileInputStream fis = new FileInputStream(new File("C:\\Users\\Zdm\\桌面\\MyStudy\\Reflect\\prop.txt"));
        prop.load(fis);
        fis.close();
        System.out.println(prop);
        String className = (String) prop.get("classname");
        String methodName = (String) prop.get("method");

        System.out.println(className);
        System.out.println(methodName);


        Class clazz = Class.forName(className);

        Constructor con = clazz.getDeclaredConstructor();
        Object o = con.newInstance();
        System.out.println(o);


        Method me = clazz.getDeclaredMethod(methodName);
        me.setAccessible(true);
        me.invoke(o);
    }
}
